import request from '@/utils/request'
import { stringify } from 'qs'

/**
 * 查询资产列表
 *
 * type 在生命周期查询中传3 资产列表传1 其他传2
 * @param {*} params
 */
export async function getList({ current = 1, type = 2, ...args }) {
  return request('/property/findPropertyList', {
    method: 'POST',
    data: {
      current,
      type,
      ...args,
    },
  })
}

/**
 * 查询资产转移单
 * @param {*} params
 */
export async function getTransList({ current = 1, ...args }) {
  return request('/chanage/getChanageList', {
    method: 'POST',
    data: {
      current,
      ...args,
    },
  })
}

/**
 * 转移单详情
 * @param {*} param0
 */
export async function getTransDetail({ id }) {
  return request(`/chanage/get/${id}`)
}

/**
 * 获取资产属性下拉列表数据
 * @param {*} params = {type}
 */
export async function getPropSelectList(params) {
  return request(`/prop/propSelectList?${stringify(params)}`, {
    method: 'GET',
  })
}

/**
 * 资产批量删除
 * @param {*} param0
 */
export async function delProperty({ ids }) {
  return request('/property/del', {
    method: 'POST',
    data: {
      ids,
    },
  })
}

/**
 * 查询资产详情
 * @param {*} param0
 */
export async function getPropDetail({ id }) {
  return request(`/property/get/${id}`, {
    method: 'GET',
  })
}

/**
 * 资产更新
 * @param {*} params
 */
export async function saveProperty(params) {
  return request('/property/edit', {
    method: 'POST',
    data: params,
  })
}

/**
 * 设置资产生命周期
 * @param {*} params
 */
export async function setPropLife(params) {
  return request('/property/updPeriodById', {
    method: 'POST',
    data: params,
  })
}

/**
 * 资产列表导出
 * @param {*} params
 */
export async function exportList(params) {
  return request('/property/expPropertyList', {
    method: 'POST',
    data: params,
  })
}

/**
 * 获取资产图片
 * @param {*} id
 */
export async function propImages({ id }) {
  return request(`/property/getImage/${id}`, {
    method: 'GET',
  })
}

/**
 * --------------------- 资产报修 -----------------------------
 */

/**
 * 报修单列表
 * @param {*} params
 */
export async function getRepairList({ current = 1, ...args }) {
  return request('/repair/getRepairList', {
    method: 'POST',
    data: {
      current,
      ...args,
    },
  })
}

/**
 * 报修单批量删除
 * @param {*} param0
 */
export async function delPropRepair({ ids }) {
  return request('/repair/del', {
    method: 'POST',
    data: {
      ids,
    },
  })
}

/**
 * 查询保修单详情
 * @param {*} param0
 */
export async function getPropRepairDetail({ id }) {
  return request(`/repair/get/${id}`, {
    method: 'GET',
  })
}

/**
 * 报修单更新
 * @param {*} params
 */
export async function saveRepairUpdate(params) {
  return request('/repair/edit', {
    method: 'POST',
    data: params,
  })
}

/**
 * --------------------- 资产报废 -----------------------------
 */

/**
 * 报修单列表
 * @param {*} params
 */
export async function getScrapList({ current = 1, ...args }) {
  return request('/scrap/getScrapList', {
    method: 'POST',
    data: {
      current,
      ...args,
    },
  })
}

/**
 * 报修单批量删除
 * @param {*} param0
 */
export async function delPropScrap({ ids }) {
  return request('/scrap/del', {
    method: 'POST',
    data: {
      ids,
    },
  })
}

/**
 * 查询保修单详情
 * @param {*} param0
 */
export async function getPropScrapDetail({ id }) {
  return request(`/scrap/get/${id}`, {
    method: 'GET',
  })
}

/**
 * 报修单更新
 * @param {*} params
 */
export async function saveScrapUpdate(params) {
  return request('/scrap/edit', {
    method: 'POST',
    data: params,
  })
}
